package com.leen.admin.entity;


import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author 
 * 角色信息表
 */
@Getter
@Setter
@Entity
@Table(name = "sys_role")
@ApiModel(value = "角色模型")
public class Role  implements Serializable {
    /**
     * 角色ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "role_id")
    @ApiModelProperty(value = "角色ID")
    private Integer roleId;

    /**
     * 角色名字
     */
    @Column(name = "role_name")
    @ApiModelProperty(value = "角色名字")
    @NotBlank(message = "角色名字不能为空")
    private String roleName;

    /**
     * 角色权限字符串
     */
    @Column(name  = "role_key")
    @ApiModelProperty(value = "角色权限字符串")
    @NotBlank(message = "角色权限字符串不能为空")
    private String roleKey;

    /**
     * 角色状态（0正常 1停用）
     */
    @Column(name  = "status")
    private Integer status;


    /**
     * 创建人
     */
    @Column( name = "create_by")
    @ApiModelProperty(value = " 创建人")
    private String createBy;


    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = " 创建时间")
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 修改者
     */
    @Column(name = "update_by" )
    @ApiModelProperty(value = " 修改者")
    private String updateBy;

    /**
     *修改时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = " 修改时间")
    @Column( name = "update_time")
    private Date updateTime;

    @JSONField(serialize = false)
    @OneToMany(cascade = CascadeType.ALL, targetEntity = AdminRole.class,mappedBy = "role",fetch = FetchType.LAZY)
    private List<AdminRole> adminRoleList;

    private static final long serialVersionUID = 1L;

    //角色拥有的菜单
    @JSONField(serialize = false)
    @OneToMany(cascade = CascadeType.ALL,targetEntity =RoleMenu.class,mappedBy = "role",fetch =  FetchType.LAZY)
    private List<RoleMenu> roleMenuList;
}